Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: add jj operation show and jj operation diff commands #3617

Merged
merged 4 commits into from
Jul 22, 2024

Conversation

bnjmnt4n
Copy link
Collaborator

@bnjmnt4n bnjmnt4n commented May 3, 2024

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch 3 times, most recently from 7e11943 to eb59a88 Compare May 4, 2024 20:56
@bnjmnt4n bnjmnt4n changed the title cli: add jj operation diff command cli: add jj operation show and jj operation diff commands May 4, 2024
lib/src/revset_graph.rs Outdated Show resolved Hide resolved
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch from eb59a88 to c82584f Compare May 4, 2024 21:02
lib/src/revset_graph.rs Outdated Show resolved Hide resolved
lib/src/revset_graph.rs Outdated Show resolved Hide resolved
lib/src/revset_graph.rs Outdated Show resolved Hide resolved
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch 2 times, most recently from 7ae89e3 to c3343eb Compare May 6, 2024 11:24
@bnjmnt4n bnjmnt4n marked this pull request as ready for review May 6, 2024 11:25
@bnjmnt4n
Copy link
Collaborator Author

bnjmnt4n commented May 6, 2024

I'm not particularly sure what to test, any suggestions on test cases to add? Maybe some common operations like squash, rebase, git fetch and push?

@bnjmnt4n
Copy link
Collaborator Author

bnjmnt4n commented May 6, 2024

I'm also thinking that templates are a good idea, maybe something like ModifiedChange nodes and ModifiedBranch nodes if that makes sense? Although the commit summary is a good starting point, seeing things like hidden repeatedly on removed commits isn't particularly useful. I'm not sure if the branch status is useful as well since, it will also be shown in the modified branches section.

@joyously
Copy link

joyously commented May 6, 2024

I'm not particularly sure what to test, any suggestions on test cases to add? Maybe some common operations like squash, rebase, git fetch and push?

I think you need to exercise the code for each option that the command handles.
If you expect edge cases for different operations, test that. I expect undo to work the same as other commands, but a test should prove it. Maybe abandon or branch create would be good to test that not just the commits but the meta data of the operation is shown or diffed correctly.

@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch from c3343eb to dbb9cec Compare May 15, 2024 01:44
@martinvonz
Copy link
Owner

@bnjmnt4n bnjmnt4n marked this pull request as ready for review 2 weeks ago

Sorry, I missed this event. GitHub doesn't send an email for it. I'll try to remember to review this later today.

@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch from dbb9cec to 33ee8dd Compare May 18, 2024 18:29
@martinvonz
Copy link
Owner

I think this really should have some tests. I'll review the code now.

@bnjmnt4n
Copy link
Collaborator Author

I'll try to add some testcases when I have the time. Here's the list of operations I think we should test (feel free to suggest more):

  • new
  • abandon
  • squash
  • rebase
  • branch create
  • git fetch
  • git push
  • op undo
  • op restore

I'm not sure how to structure it though: I guess I should add a single test beginning from an empty repo for each of these operations?

Copy link
Collaborator

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems useful, but I haven't reviewed the last patch thoroughly. It's a bit hard to comment on the features without snapshot tests.

lib/src/graph.rs Outdated Show resolved Hide resolved
lib/src/graph.rs Outdated Show resolved Hide resolved
cli/src/commands/operation.rs Outdated Show resolved Hide resolved
cli/src/commands/operation.rs Outdated Show resolved Hide resolved
cli/src/commands/operation.rs Outdated Show resolved Hide resolved
@bnjmnt4n
Copy link
Collaborator Author

Thanks for taking a look @yuja. I'll try to work on adding some tests to make it easier to see what the expected output is like, perhaps further reviews can be put on hold if you'd like.

I'm also thinking that templates are a good idea, maybe something like ModifiedChange nodes and ModifiedBranch nodes if that makes sense? Although the commit summary is a good starting point, seeing things like hidden repeatedly on removed commits isn't particularly useful. I'm not sure if the branch status is useful as well since, it will also be shown in the modified branches section.

I'd also like to see if there's any desire to change the output displayed.

@martinvonz
Copy link
Owner

I'll try to add some testcases when I have the time. Here's the list of operations I think we should test (feel free to suggest more):

  • new
  • abandon
  • squash
  • rebase
  • branch create
  • git fetch
  • git push

As @joyously said, it's probably best to instead focus on what the code does and the different cases it handles. For example, there's some logic for displaying how refs moved, so there should be some tests demonstrating that, and ideally some including conflicted refs. It doesn't matter which commands you use to create the refs, so use whatever is easiest for that (for creating conflicted branches, it's probably easiest to use jj branch set --at-op=...).

  • op undo
  • op restore

I don't think these two need to be tested. They don't do much you can't test by making the same changes explicitly.

I'm not sure how to structure it though: I guess I should add a single test beginning from an empty repo for each of these operations?

SGTM.

cli/src/commands/log.rs Outdated Show resolved Hide resolved
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch 2 times, most recently from 5445df7 to 8b1ebd4 Compare July 6, 2024 09:09
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch from 8b1ebd4 to 5fca665 Compare July 9, 2024 19:15
@bnjmnt4n bnjmnt4n marked this pull request as ready for review July 9, 2024 19:16
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch 2 times, most recently from 82d025f to 3be04a7 Compare July 16, 2024 15:31
@bnjmnt4n
Copy link
Collaborator Author

I've updated this PR with tests. Would appreciate input on whether the output should change in any way, as well as any changes to the tests.

@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch from 3be04a7 to c0de384 Compare July 16, 2024 15:40
Copy link
Owner

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output looks good to me for now. I think it will be easier to figure out what changes we want to make once we start using these commands. Thanks again! This seems really useful for troubleshooting.

lib/src/repo.rs Outdated Show resolved Hide resolved
cli/tests/test_operations.rs Outdated Show resolved Hide resolved
cli/tests/test_operations.rs Outdated Show resolved Hide resolved
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch from c0de384 to 290ce09 Compare July 17, 2024 09:52
cli/src/commands/operation/diff.rs Outdated Show resolved Hide resolved
cli/src/commands/operation/diff.rs Show resolved Hide resolved
cli/src/commands/operation/diff.rs Show resolved Hide resolved
cli/src/commands/operation/show.rs Outdated Show resolved Hide resolved
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch 2 times, most recently from f4f3b35 to 91ea230 Compare July 20, 2024 19:54
@bnjmnt4n
Copy link
Collaborator Author

@yuja would appreciate if you could take another look. I've updated to avoid creating a transaction for jj op show, and used the new commit_summary_template helper as well.

Copy link
Collaborator

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

cli/src/commands/operation/diff.rs Outdated Show resolved Hide resolved
cli/src/commands/operation/diff.rs Outdated Show resolved Hide resolved
cli/src/commands/operation/diff.rs Outdated Show resolved Hide resolved
cli/src/commands/operation/diff.rs Outdated Show resolved Hide resolved
cli/src/commands/operation/diff.rs Show resolved Hide resolved
cli/src/commands/operation/diff.rs Outdated Show resolved Hide resolved
cli/tests/test_operations.rs Outdated Show resolved Hide resolved
cli/src/commands/operation/show.rs Outdated Show resolved Hide resolved
cli/src/commands/operation/show.rs Outdated Show resolved Hide resolved
cli/src/commands/operation/show.rs Outdated Show resolved Hide resolved
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch from 91ea230 to 4a77667 Compare July 21, 2024 19:15
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-uzynoulwtlvz branch from 4a77667 to 58594af Compare July 22, 2024 09:45
@bnjmnt4n bnjmnt4n merged commit dade156 into main Jul 22, 2024
29 checks passed
@bnjmnt4n bnjmnt4n deleted the bnjmnt4n/push-uzynoulwtlvz branch July 22, 2024 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants